package com.chanyachting.emall.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import com.chanyachting.emall.util.RequestUtil;

public class ProductcategoryForm extends ActionForm {
	
	// primary key
	private java.lang.Integer id;

	// fields
	private java.lang.Integer businesscategoryId;
	private java.lang.Integer pri;
	private java.lang.String name;
	private java.lang.String summary;
	public java.lang.Integer getId() {
		return id;
	}
	public void setId(java.lang.Integer id) {
		this.id = id;
	}
	public java.lang.Integer getBusinesscategoryId() {
		return businesscategoryId;
	}
	public void setBusinesscategoryId(java.lang.Integer businesscategoryId) {
		this.businesscategoryId = businesscategoryId;
	}
	public java.lang.Integer getPri() {
		return pri;
	}
	public void setPri(java.lang.Integer pri) {
		this.pri = pri;
	}
	public java.lang.String getName() {
		return name;
	}
	public void setName(java.lang.String name) {
		this.name = name;
	}
	public java.lang.String getSummary() {
		return summary;
	}
	public void setSummary(java.lang.String summary) {
		this.summary = summary;
	}
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		
		
		ActionErrors errors=new ActionErrors();
		
		String msg="";
		
		if(name==null || name.trim().equals("")){
			
			errors.add("sellname", new ActionMessage("errors.businesstype.nameEmpty")); 
			
			msg="name must not null!";
			
		}
		
		if(this.getBusinesscategoryId()==0){
			
			errors.add("sellname", new ActionMessage("errors.businesstype.nameEmpty")); 
			
			msg+=" businesstCategory_id must not null!";
			
		}
		
		new RequestUtil(request).setMsg(msg);
		
		return errors;
	}

	
	
	
	


}
